const app=getApp();
Page({
  data: {
    arrayList:[],
    arr:''
  },
  playWhat(){
    var id=Math.floor(Math.random()*3);
    var arr=this.data.arrayList[id];
    this.setData({arr:arr})
    console.log(arr)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.playWhat()
    wx.request({
      url:`${app.globalData.url}/playbook`,
      dataType:'json',
      method:'GET',
      header:{
        "content-type":'application/json'
      },
      success:res=>{
          console.log(res.data);
          this.setData({
            arrayList:res.data
            // 将获取到的数据传给初始化的变量，在后端渲染
          })
          this.playWhat();
      },
      fail(){
        console.log("no");
      }
    })
   
  }
})